package com.wanmait.employment.manageController;

import com.wanmait.employment.entity.WorkExperience;
import com.wanmait.employment.service.WorkExperienceService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/manage/WorkExperience")
public class WorkExperienceController {
    @Resource
    private WorkExperienceService workExperienceService;

    @GetMapping("list")
    public AjaxResult list(String title){
        List<WorkExperience> workExperiences = workExperienceService.selectList(title);
        return AjaxResult.success("",workExperiences);
    }
    @PostMapping("update")
    public AjaxResult update(@RequestBody WorkExperience workExperience){
        if(workExperience.getId()!=null){
            workExperienceService.update(workExperience);
            return AjaxResult.success("");
        }
        workExperienceService.insert(workExperience);
        return AjaxResult.success("");
    }
    @GetMapping("delete")
    public AjaxResult delete(Integer id){
        workExperienceService.delete(id);
        return  AjaxResult.success("");
    }
}
